package ioc

import (
	"github.com/robfig/cron/v3"
	"jk-time/webook/payment/job"
	"jk-time/webook/payment/service/wechat"
	"jk-time/webook/pkg/jobx"
	"jk-time/webook/pkg/logger"
)

func InitJobs(svc wechat.NativePaymentService, l logger.Logger) *cron.Cron {
	wechatJob := job.NewSyncWechatOrderJob(svc, l)

	// 依靠适配器实现wechatJob变成job
	jobN := jobx.NewCronJobBuilder("ranking_job", "wechat_order", "wechat_order_job",
		"执行wechat_order校验循环任务").Build(wechatJob)

	cronN := cron.New(cron.WithSeconds())
	_, err := cronN.AddJob("* */30 * * * ?", jobN)
	if err != nil {
		panic(err)
	}
	//jobN.Run()
	return cronN
}
